#ifndef SPOKE_DART_H_
#define SPOKE_DART_H_

#include <vector>
#include <list>
#include "vectorD.h"
#include "dart.h"

class SpokeDartFrontSample
{
public:
	SpokeDartFrontSample(const VectorD& point, unsigned int sampleIndex) : point_(point), sampleIndex_(sampleIndex), failureCount_(0) {}
	virtual ~SpokeDartFrontSample() {}

	VectorD point_;
	unsigned int failureCount_;
	unsigned int sampleIndex_;
};

class SpokeDart : public Dart
{
public:
	SpokeDart();
	virtual ~SpokeDart();

	virtual void reset(unsigned int d, const VectorD& front, DATA_TYPE radius);

	virtual void updateIntervals(const std::vector<VectorD>& points, DATA_TYPE radius);
	virtual bool pickPoint(VectorD& point);
protected:

	DATA_TYPE raisePower(DATA_TYPE value);
	DATA_TYPE lowerPower(DATA_TYPE value);

	VectorD refPoint_;
	VectorD direction_;
	unsigned int dartDimensionIndex_;
	std::list<Interval> intervals_;
	unsigned int dimensions_;
	DATA_TYPE invDimensions_;
};

inline DATA_TYPE SpokeDart::raisePower(DATA_TYPE value)
{
	if (value > 0)
		return pow(value, (DATA_TYPE)dimensions_);
	else
		return -pow(-value, (DATA_TYPE)dimensions_);
}

inline DATA_TYPE SpokeDart::lowerPower(DATA_TYPE value)
{
	if (value > 0)
		return pow(value, invDimensions_);
	else
		return -pow(-value, invDimensions_);
}

#endif